
#pragma once
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
#ifdef __GNUC__ //gnu gcc/g++
#include <stdint.h>
#include <inttypes.h>
#endif // __GNUC__
#include <windows.h>
#include "LogLevel.h"
/*
	自控制宏
*/

/* enable log output. default open this macro */
#define ELOG_OUTPUT_ENABLE
/* setting static output log level */
#define ELOG_OUTPUT_LVL                      ELOG_LVL_VERBOSE
/* enable assert check */
#define ELOG_ASSERT_ENABLE
/* log buffer size */
#define ELOG_BUF_SIZE                        512
/* output line number max length */
#define ELOG_LINE_NUM_MAX_LEN                5
/* output filter's tag max length */
#define ELOG_FILTER_TAG_MAX_LEN              16
/* output filter's keyword max length */
#define ELOG_FILTER_KW_MAX_LEN               16
/* output newline sign */
#define ELOG_NEWLINE_SIGN                    "\n"

/*
	基础定义
	*/


#if !defined(ELOG_OUTPUT_LVL)
#error "Please configure static output log level (in elog_cfg.h)"
#endif

#if !defined(ELOG_LINE_NUM_MAX_LEN)
#error "Please configure output line number max length (in elog_cfg.h)"
#endif

#if !defined(ELOG_BUF_SIZE)
#error "Please configure log buffer size (in elog_cfg.h)"
#endif

#if !defined(ELOG_FILTER_TAG_MAX_LEN)
#error "Please configure output filter's tag max length (in elog_cfg.h)"
#endif

#if !defined(ELOG_FILTER_KW_MAX_LEN)
#error "Please configure output filter's keyword max length (in elog_cfg.h)"
#endif

#if !defined(ELOG_NEWLINE_SIGN)
#error "Please configure output newline sign (in elog_cfg.h)"
#endif

/* output log's level total number */
#define ELOG_LVL_TOTAL_NUM                   6

/* EasyLogger software version number */
#define ELOG_SW_VERSION                      "1.01"

/* all formats index */
typedef enum {
	ELOG_FMT_LVL = 1 << 0, /**< level */
	ELOG_FMT_TAG = 1 << 1, /**< tag */
	ELOG_FMT_TIME = 1 << 2, /**< current time */
	ELOG_FMT_P_INFO = 1 << 3, /**< process info */
	ELOG_FMT_T_INFO = 1 << 4, /**< thread info */
	ELOG_FMT_DIR = 1 << 5, /**< file directory and name */
	ELOG_FMT_FUNC = 1 << 6, /**< function name */
	ELOG_FMT_LINE = 1 << 7, /**< line number */
} ElogFmtIndex;

/* macro definition for all formats */
#define ELOG_FMT_ALL    (ELOG_FMT_LVL|ELOG_FMT_TAG|ELOG_FMT_TIME|ELOG_FMT_P_INFO|ELOG_FMT_T_INFO| \
	ELOG_FMT_DIR | ELOG_FMT_FUNC | ELOG_FMT_LINE)

/* output log's filter */
typedef struct {
	uint8_t level;
	char tag[ELOG_FILTER_TAG_MAX_LEN + 1];
	char keyword[ELOG_FILTER_KW_MAX_LEN + 1];
} ElogFilter, *ElogFilter_t;

/* easy logger */
typedef struct {
	ElogFilter filter;
	size_t enabled_fmt_set[ELOG_LVL_TOTAL_NUM];
	bool output_enabled;
}EasyLogger, *EasyLogger_t;

/* EasyLogger error code */
typedef enum {
	ELOG_NO_ERR,
} ElogErrCode;
